import request from '@/utils/request'

// 查询字典数据
export function getDictData(dictType) {
  return request({
    url: '/common/dict/' + dictType,
    method: 'get',
    headers: {
      isToken: false,
    },
  })
}

// 查询字典数据
export function getConfig(configKey) {
  return request({
    url: '/common/config/' + configKey,
    method: 'get',
    headers: {
      isToken: false,
    },
  })
}

// 查询字典数据
export function getCategoryOptions(baseCode) {
  return request({
    url: '/common/category/' + baseCode,
    method: 'get',
    headers: {
      isToken: false,
    },
  })
}

// 查询枚举数据
export function getStaticData(code, url, query) {
  url = url === undefined ? '/common/static/' + code : url + '/' + code
  return request({
    url: url,
    method: 'get',
    params: query,
    headers: {
      isToken: false,
    },
  })
}

export function getQRCode(query) {
  return request({
    url: '/common/qrCode',
    method: 'get',
    params: query,
    responseType: 'blob',
    headers: {
      isToken: false,
    },
  })
}

export function getAction(url, query, publicFlag) {
  publicFlag = publicFlag === undefined ? false : publicFlag
  return request({
    url: url,
    method: 'get',
    params: query,
    headers: {
      isToken: !publicFlag,
    },
  })
}

export function postAction(url, data, publicFlag) {
  publicFlag = publicFlag === undefined ? false : publicFlag
  return request({
    url: url,
    method: 'post',
    data: data,
    headers: {
      isToken: !publicFlag,
    },
  })
}

export function putAction(url, data) {
  return request({
    url: url,
    method: 'put',
    data: data,
  })
}

export function deleteAction(url, data) {
  return request({
    url: url,
    method: 'delete',
    data: data,
  })
}
